<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="vue.js"></script>
    <style>


    </style>
</head>

<body>
    <main id="app">
            <img :src="'img/'+ index +'.png'" @mousedown.prevent='md($event)'>
    </main>

    <script>
    var vue = new Vue({
        el: "#app",
        data: {
            index:1,
            carPointx:0
        },
        methods: {
            md:function(e){
                var that =this
                this.carPointx =e.pageX
                var mv = function(e){
                    that.point(e)
                }
                document.addEventListener('mousemove',mv)
                document.addEventListener('mouseup',function(){
                        document.removeEventListener('mousemove',mv)
                    })
            },
            point:function(e){
                // console.log(e)
                var pointX = e.clientX
                if(this.index>=23){
                    this.index=1
                }
                if(this.index<1){
                     this.index=23
                }
                if(this.carPointx >pointX){
                    this.index++
                }
                if(this.carPointx <pointX){
                    this.index--
                }

            }
        },
    })

    </script>
</body>

</html>